#include "data_types.h"

const QString kId("id");
const QString kUserId("user_id");
const QString kRecommendUser("recommend_user");
const QString kName("name");
const QString kSubName("sub_name");
const QString kFullName("full_name");
const QString kEnglishName("enlish_name");
const QString kCategory("category");
const QString kSubCate("subcate");
const QString kTags("tags");
const QString kLocation("location");
const QString kAddress("address");
const QString kEnglishAddress("english_address");
const QString kShowImageUrl("show_image_url");
const QString kThumbImageUrl("thumb_image_url");
const QString kDistrict("district");
const QString kRegion("region");
const QString kContact("contact");
const QString kWebsite("website");
const QString kPVerity("p_verify");
const QString kBackupVerity("backup_verity");
const QString kHomeId("home_id");
const QString kHomeName("home_name");
const QString kAroundList("around_list");
const QString kPriceOption("price_option");
const QString kZongheSort("zonghe_sort");
const QString kHuanjingSort("huanjing_sort");
const QString kFuwuSort("fuwu_sort");
const QString kZhiliangSort("zhiliang_sort");
const QString kXingjiabiSort("xingjiabi_sort");
const QString kKouweiSort("kouwei_sort");
const QString kRank("rank");
const QString kOrderRank("order_rank");
const QString kStarCount("star_count");
const QString kViewCount("view_count");
const QString kCommentCount("comment_count");
const QString kRecommendCount("recommend_count");
const QString kCheckinCount("checkin_count");
const QString kAibangId("aibang_id");
const QString kDianpingId("dianping_id");
const QString kKoubeiId("koubei_id");
const QString kLat("lat");
const QString kLng("lng");
const QString kMatchLevel("match_level");
const QString kCoordinateX("coordinate_x");
const QString kCoordinateY("coordinate_y");
const QString kCreatedOn("created_on");
const QString kUpdatedOn("updated_on");
const QString kLastCommentTime("last_comment_time");
const QString kBody("body");
const QString kDescription("description");

int parse_place(QDomElement &e, place &p) {
    QDomNodeList list = e.childNodes();
    for (int i = 0; i < list.count(); ++i) {
        QDomElement n = list.at(i).toElement();
        int v = n.text().toInt();
        if (n.nodeName() == kId) {
            p.id = v;
        }
        if (n.nodeName() == kUserId) {
            p.user_id = v;
        }
        if (n.nodeName() == kRecommendUser) {
            p.recommend_user = v;
        }
        if (n.nodeName() == kName) {
            p.name = n.text();
        }
        if (n.nodeName() == kSubName) {
            p.sub_name = n.text();
        }
        if (n.nodeName() == kFullName) {
            p.full_name = n.text();
        }
        if (n.nodeName() == kEnglishName) {
            p.enlish_name = n.text();
        }
        if (n.nodeName() == kCategory) {
            p.category = n.text();
        }
        if (n.nodeName() == kSubCate) {
            p.subcate = n.text();
        }
        if (n.nodeName() == kTags) {
            p.tags = n.text();
        }
        if (n.nodeName() == kLocation) {
            p.location = n.text();
        }
        if (n.nodeName() == kAddress) {
            p.address = n.text();
        }
        if (n.nodeName() == kEnglishAddress) {
            p.english_address = n.text();
        }
        if (n.nodeName() == kShowImageUrl) {
            p.show_image_url = n.text();
        }
        if (n.nodeName() == kThumbImageUrl) {
            p.thumb_image_url = n.text();
        }
        if (n.nodeName() == kDistrict) {
            p.district = n.text();
        }
        if (n.nodeName() == kRegion) {
            p.region = n.text();
        }
        if (n.nodeName() == kContact) {
            p.contact = n.text();
        }
        if (n.nodeName() == kWebsite) {
            p.website = n.text();
        }
        if (n.nodeName() == kPVerity) {
            p.p_verify = v;
        }
        if (n.nodeName() == kBackupVerity) {
            p.backup_verity = v;
        }
        if (n.nodeName() == kHomeId) {
            p.home_id = v;
        }
        if (n.nodeName() == kHomeName) {
            p.home_name = n.text();
        }
        if (n.nodeName() == kAroundList) {
            p.around_list = n.text();
        }
        if (n.nodeName() == kPriceOption) {
            p.price_option = v;
        }
        if (n.nodeName() == kZongheSort) {
            p.zonghe_sort = v;
        }
        if (n.nodeName() == kHuanjingSort) {
            p.huanjing_sort = v;
        }
        if (n.nodeName() == kFuwuSort) {
            p.fuwu_sort = v;
        }
        if (n.nodeName() == kZhiliangSort) {
            p.zhiliang_sort = v;
        }
        if (n.nodeName() == kXingjiabiSort) {
            p.xingjiabi_sort = v;
        }
        if (n.nodeName() == kKouweiSort) {
            p.kouwei_sort = v;
        }
        if (n.nodeName() == kRank) {
            p.rank = v;
        }
        if (n.nodeName() == kOrderRank) {
            p.order_rank = v;
        }
        if (n.nodeName() == kStarCount) {
            p.star_count = v;
        }
        if (n.nodeName() == kViewCount) {
            p.view_count = v;
        }
        if (n.nodeName() == kCommentCount) {
            p.comment_count = v;
        }
        if (n.nodeName() == kRecommendCount) {
            p.recommend_count = v;
        }
        if (n.nodeName() == kCheckinCount) {
            p.checkin_count = v;
        }
        if (n.nodeName() == kAibangId) {
            p.aibang_id = v;
        }
        if (n.nodeName() == kDianpingId) {
            p.dianping_id = v;
        }
        if (n.nodeName() == kKoubeiId) {
            p.koubei_id = v;
        }
        if (n.nodeName() == kLat) {
            p.lat = n.text();
        }
        if (n.nodeName() == kLng) {
            p.lng = n.text();
        }
        if (n.nodeName() == kMatchLevel) {
            p.match_level = v;
        }
        if (n.nodeName() == kCoordinateX) {
            p.coordinate_x = n.text();
        }
        if (n.nodeName() == kCoordinateY) {
            p.coordinate_y = n.text();
        }
        if (n.nodeName() == kCreatedOn) {
            p.created_on = n.text();
        }
        if (n.nodeName() == kUpdatedOn) {
            p.updated_on = n.text();
        }
        if (n.nodeName() == kLastCommentTime) {
            p.last_comment_time = n.text();
        }
        if (n.nodeName() == kBody) {
            p.body = n.text();
        }
        if (n.nodeName() == kDescription) {
            p.description = n.text();
        }
    }

    return 0;
}
